<template>
	<div class="container" ref="refContainer">
		<div class="doc-content">
			<div class="title">
				Timepicker时间选择器
			</div>
			<!-- <div class="sub-title quote">
				由于这是一个API组件，应使用API的方式来调用
			</div> -->
			
			<div class="example-title">引入方式（按需）</div>
			<code-view>
				<template slot="code-js">{{ jsCode1 }}</template>
			</code-view>
			
			<div class="example-title">基本用法</div>
			<code-view>
				<template slot="code-html">{{ htmlCode2 }}</template>
				<template slot="code-js">{{ jsCode2 }}</template>
			</code-view>
			
			<br>
			
			<div id="parameter-list" class="example-title">&lt;gr-timepicker&gt;属性</div>
			<gr-table :width="800" :tableData="propertiesExplain1" textAlign="left">
				<template v-slot="{rowData}">
					<gr-table-column label="参数名称" width="150">
						{{rowData.attrName}}
					</gr-table-column>
					<gr-table-column label="参数说明" width="190">
						{{rowData.introduce}}
					</gr-table-column>
					<gr-table-column label="类型" width="110">
						{{rowData.type}}
					</gr-table-column>
					<gr-table-column label="可选值" width="100">
						{{rowData.optionValues}}
					</gr-table-column>
					<gr-table-column label="默认值" width="100">
						{{rowData.defaultValue}}
					</gr-table-column>
				</template>
			</gr-table>
			
			<div class="example-title">&lt;gr-timepicker&gt;事件</div>
			<gr-table :width="800" :tableData="propertiesExplain2" textAlign="left">
				<template v-slot="{rowData}">
					<gr-table-column label="方法名称" width="100">
						{{rowData.attrName}}
					</gr-table-column>
					<gr-table-column label="方法说明" width="150">
						{{rowData.introduce}}
					</gr-table-column>
					<gr-table-column label="参数" width="120">
						{{rowData.param}}
					</gr-table-column>
				</template>
			</gr-table>
		</div>
		<div class="demo-view">
			<div ref="refCellPhone" class="cellphone">
				<iframe src="demo.html#/timePickerdemo" frameborder="0" width="100%" height="100%"></iframe>
			</div>
		</div>
	</div>
</template>

<script>
	
	import Demo from '../components/Demo.vue'
	import CodeView from '../components/CodeView.vue'
	export default {
		components: {
			Demo, CodeView
		},
		data() {
			return {
jsCode1: `import {TimePicker} from 'gabriel-ui'
Vue.use(TimePicker)`,
htmlCode2: `<gr-input disabled v-model="createTime" suffix-icon="arrow-right-bold" 
	@icon-click="showTimePicker" />
<gr-popup v-model="isShowTimePicker">
	<gr-timepicker v-model="createTime" 
		@confirm="hideTimePicker" @cancel="hideTimePicker"/>
</gr-popup>`,
jsCode2: `export default {
	data() {
		return {
			createTime: '18:30',
			isShowTimePicker: false
		}
	},
	methods: {
		showTimePicker() {
			this.isShowTimePicker = true;
		},
		hideTimePicker() {
			this.isShowTimePicker = false;
		}
	}
}`,
				propertiesExplain1: [
					{
						attrName: 'v-model',
						introduce: `绑定的value值，时间格式: HH:mm`,
						type: 'String',
						optionValues: '----',
						defaultValue: '08:00'
					}
				],
				propertiesExplain2: [
					{
						attrName: 'confirm',
						introduce: `点击确定时触发该事件`,
						param: '绑定的value值'
					},
					{
						attrName: 'cancel',
						introduce: `点击取消时触发该事件`,
						param: '绑定的value值'
					}
				]
			}
		},
		mounted() {
			let ele = this.$refs.refCellPhone
			this.$refs.refContainer.addEventListener('scroll', (e)=> {
				ele.style.top = e.target.scrollTop + 'px';
			})
		},
		methods: {
			click(e) {
				this.$toast.show('这是一个吐司提示', 1000)
			}
		}
	}
</script>

<style lang="scss">
	
</style>
